<script>
	import $store from './store/index.js';
	import {
	    userOauthLogin
	} from '@/api/login.js';
	export default {
		onLaunch: function(querys) {
			console.log('App Launch')
			$store.dispatch('user/USER_CONFIG')
			//获取手机上面安全距离
			$store.dispatch('phone/SET_PHONE_NAME_ACT')
			//获取省市区地址
			/*let addressCodeList = uni.getStorageSync('_ADDRESS_CODE')
			if (addressCodeList.length == 0 || !addressCodeList) {
				get_address_code().then(res => {
					if (res.code == 0) {
						uni.setStorageSync('_ADDRESS_CODE', res.data)
					}
				}).catch(err => {})
			}*/
			var launchOptions = uni.getLaunchOptionsSync();
			let query = launchOptions.query;
			var user_relation = '';
			if(launchOptions.query.share_code){
				user_relation = launchOptions.query.share_code;
			}
			var that = this;
			//静默授权登录
			// #ifdef MP-WEIXIN
			uni.login({
			    provider: 'weixin',
			    success:function (res){
					userOauthLogin({code: res.code,user_relation:user_relation}).then(response=>{
						if (response.code == 0) {
							uni.setStorageSync('_USER_ACCESS_TOKEN', response.data.token);
							that.$store.dispatch('user/USER_CONFIG')
						}
					})
			    }
			})
			// #endif
		},
		onShow: function() {
			 this.globalData.web_name = '云手机助手';
		},
		globalData: {
		  web_name: ''
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style  lang="scss">
	/*每个页面公共css */
	/*每个页面公共css */
	@import "uview-ui/index.scss";
	
	// 全局样式
	:not(not) {
		box-sizing: border-box;
	}
</style>
